<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
    <style type="text/css">
        body, html, #allmap {
            width: 100%;
            height: 100%;
            overflow: hidden;
            margin: 0;
            font-family: "微软雅黑";
        }

        #l-map {
            height: 100%;
            width: 78%;
            float: left;
            border-right: 2px solid #bcbcbc;
        }

        #r-result {
            height: 100%;
            width: 20%;
            float: left;
        }

        .BMapLabel {
            max-width: none;
        }
    </style>
    <script type="text/javascript"
            src="http://api.map.baidu.com/api?v=2.0&ak=F19q5OcuWjjkMN55MFhqBU1h3GFfW0S3"></script>
    <title>添加多个标注点</title>
</head>
<body>
<div id="allmap"></div>
</body>
</html>
<script type="text/javascript">
    // 百度地图API功能
    var map = new BMap.Map("allmap");
    var point = new BMap.Point(111.183485, 21.652753);
    map.centerAndZoom(point, 15);
    map.enableScrollWheelZoom();
    var myArray = new Array();
    // 编写自定义函数,创建标注
    myArray.push(new BMap.Point(111.183485, 21.652753));
    myArray.push(new BMap.Point(111.183493, 21.65223));
    myArray.push(new BMap.Point(111.183531, 21.649953));
    myArray.push(new BMap.Point(111.183351, 21.649952));
    myArray.push(new BMap.Point(111.178906, 21.649795));
    myArray.push(new BMap.Point(111.177644, 21.65221));
    myArray.push(new BMap.Point(111.177531, 21.652253));
    myArray.push(new BMap.Point(111.177704, 21.657318));
    myArray.push(new BMap.Point(111.183368, 21.657381));
    myArray.push(new BMap.Point(111.183408, 21.657381));
    myArray.push(new BMap.Point(111.183485, 21.652753));

    for (var i = 0; i < myArray.length; i++) {
        var p = myArray[i];
        addMarker(p);

        var opts = {
            position: p,    // 指定文本标注所在的地理位置
            offset: new BMap.Size(0 - 30, 0 - 17)    //设置文本偏移量
        };
        var text = p.lng + "," + p.lat;
        var label = new BMap.Label(text, opts);
        label.setStyle(labelStyle);
        map.addOverlay(label);
    }

    function addMarker(point) {
        var marker = new BMap.Marker(point);
        map.addOverlay(marker);
    }

    //文本信息
    var labelStyle = {
        color: "red",
        fontSize: "12px",
        height: "20px",
        lineHeight: "20px",
        fontFamily: "微软雅黑",
        width: "400px"
    };


</script>
